package com.prolestar.web.controller.publicsentiment;


import com.prolestar.common.annotation.Log;
import com.prolestar.common.core.controller.BaseController;
import com.prolestar.common.core.domain.AjaxResult;
import com.prolestar.common.core.page.TableDataInfo;
import com.prolestar.common.enums.BusinessType;
import com.prolestar.common.utils.poi.ExcelUtil;
import com.prolestar.framework.web.service.TokenService;
import com.prolestar.publicsentiment.domain.ApportionPubilcsentiment;
import com.prolestar.publicsentiment.domain.PsDealLog;
import com.prolestar.publicsentiment.domain.PsPublicsentiment;
import com.prolestar.publicsentiment.domain.StrategyByInvolved;
import com.prolestar.publicsentiment.service.IPsPublicsentimentService;
import com.prolestar.util.MySetPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.List;


/**
 * 舆情处置Controller
 * 
 * @author ruoyi
 * @date 2022-11-11
 */
@RestController
@RequestMapping("/publicsentiment/publicsentiment")
public class PsPublicsentimentController extends BaseController
{
    @Autowired
    private IPsPublicsentimentService psPublicsentimentService;

    @Autowired
    private TokenService tokenService;

    /**
     *  首页展示数据
     */
    @GetMapping("/selectAll")
    public List<PsPublicsentiment> selectAll(){
        return psPublicsentimentService.selectAll();
    }

    /**
     * 查询舆情处置列表
     */
    @PreAuthorize("@ss.hasPermi('publicsentiment:publicsentiment:list')")
    @GetMapping("/list")
    public TableDataInfo list(PsPublicsentiment psPublicsentiment)
    {
//        startPage();
        List<PsPublicsentiment> list = psPublicsentimentService.selectPsPublicsentimentList(psPublicsentiment);
//        return getDataTable(list);
        return MySetPage.mySetPage(list);
    }

    /**
     * 导出舆情处置列表
     */
    @PreAuthorize("@ss.hasPermi('publicsentiment:publicsentiment:export')")
    @Log(title = "舆情处置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PsPublicsentiment psPublicsentiment)
    {
        List<PsPublicsentiment> list = psPublicsentimentService.selectPsPublicsentimentList(psPublicsentiment);
        ExcelUtil<PsPublicsentiment> util = new ExcelUtil<PsPublicsentiment>(PsPublicsentiment.class);
        util.exportExcel(response, list, "舆情处置数据");
    }

    /**
     * 获取舆情处置详细信息
     */
    @PreAuthorize("@ss.hasPermi('publicsentiment:publicsentiment:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(psPublicsentimentService.selectPsPublicsentimentById(id));
    }



    /**
     * 获取舆情处置详细信息
     */
    @PostMapping("/selectPSById")
    public AjaxResult selectPSById(@RequestBody PsPublicsentiment psPublicsentiment){
        return success(psPublicsentimentService.selectPSById(psPublicsentiment));
    }

    /**
     * 根据涉及问题查找应对策略
     */
    @PostMapping("/StrategyByInvolved")
    public List<StrategyByInvolved> StrategyByInvolved(@RequestBody StrategyByInvolved strategyByInvolved){
        return psPublicsentimentService.StrategyByInvolved(strategyByInvolved);

    }


    /**
     * 新增舆情处置
     */
    @PreAuthorize("@ss.hasPermi('publicsentiment:publicsentiment:add')")
    @Log(title = "舆情处置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PsPublicsentiment psPublicsentiment)
    {
        return toAjax(psPublicsentimentService.insertPsPublicsentiment(psPublicsentiment));
    }

    /**
     * 修改舆情处置
     */
    @PreAuthorize("@ss.hasPermi('publicsentiment:publicsentiment:edit')")
    @Log(title = "舆情处置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PsPublicsentiment psPublicsentiment)
    {
        return toAjax(psPublicsentimentService.updatePsPublicsentiment(psPublicsentiment));
    }

    /**
     * 删除舆情处置
     */
    @PreAuthorize("@ss.hasPermi('publicsentiment:publicsentiment:remove')")
    @Log(title = "舆情处置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return psPublicsentimentService.deletePsPublicsentimentByIds(ids);
    }

    /**
     * 舆情处置——导入
     */
    @PostMapping(value = "/toLead")
    @Log(title = "舆情处置", businessType = BusinessType.IMPORT)
    public AjaxResult toLead(MultipartFile file, boolean updateSupport) throws Exception
    {
        return psPublicsentimentService.toLead(file,updateSupport);
    }

    @GetMapping("/importTemplate")
    public AjaxResult importTemplate()
    {
        ExcelUtil<PsPublicsentiment> util = new ExcelUtil<>(PsPublicsentiment.class);
        return util.importTemplateExcel("用户数据");
    }


    /**
     * 舆情处置--分派
     */

    @PostMapping("/apportion")
    public AjaxResult apportion(@RequestBody ApportionPubilcsentiment apportionPubilcsentiment){
        return psPublicsentimentService.apportion(apportionPubilcsentiment);
    }

    /**
     * 舆情处置--处理
     */
    @PostMapping("/dispose")
    public AjaxResult dispose(@RequestBody ApportionPubilcsentiment apportionPubilcsentiment){
        return psPublicsentimentService.dispose(apportionPubilcsentiment);
    }

    /**
     * 舆情处置-- 签收
     *
     */
    @PostMapping("/sign")
    public AjaxResult sign(@RequestBody ApportionPubilcsentiment apportionPubilcsentiment){
        return psPublicsentimentService.sign(apportionPubilcsentiment);
    }
    /**
     * 舆情处置-- 已读
     *
     */
    @PostMapping("/read")
    public AjaxResult read(@RequestBody ApportionPubilcsentiment apportionPubilcsentiment){
        return psPublicsentimentService.read(apportionPubilcsentiment);
    }

    /**
     * 舆情处置-- 退回
     *
     */
    @PostMapping("/sendBack")
    public AjaxResult sendBack(@RequestBody ApportionPubilcsentiment apportionPubilcsentiment){
        return psPublicsentimentService.sendBack(apportionPubilcsentiment);
    }

    /**
     * 舆情处置-- 关注状态
     *
     */
    @PostMapping("/specialFocus")
    public AjaxResult specialFocus(@RequestBody PsPublicsentiment psPublicsentiment){
        return psPublicsentimentService.specialFocus(psPublicsentiment);
    }

    /**
     * 详情--查询处置情况
     */
    @PostMapping("/taskList")
    public List<ApportionPubilcsentiment> taskList(@RequestBody ApportionPubilcsentiment apportionPubilcsentiment){
        return psPublicsentimentService.taskList(apportionPubilcsentiment);
    }

    /**
     * 详情-- 操作记录
     */
    @PostMapping("/selectOperation")
    public List<PsDealLog> selectOperation(@RequestBody PsDealLog psDealLog){
        return psPublicsentimentService.selectOperation(psDealLog);
    }




}
